﻿package Classes.Elements{
	import flash.display.*;
	import flash.events.*;
	import flash.utils.*;
	
	import Classes.Utils.*;
	import Classes.*;
	import Classes.Interface.*;
	import Classes.Layers.*;
	import Classes.Explode.*;
	
	//场景中所有可被摧毁的对象的基类，有生命值和更复杂的运动方式
	public class Element extends BasicElement implements ILife{ 
		//分值
		protected var _score:Number;		
		//生命值
		protected var _hp:Number;
		//最大生命值
		public var life:Number;
		//破坏力
		public var execution:Number;
		//横向状态
		public var hstate:int;
		//纵向状态
		public var vstate:int;		
		//由哪一个对象摧毁的
		public var killer:Element;
		//是否能够被伤害
		public var hurtable:Boolean;		
		//条件参数，用来处理一些特殊情况
		public var condition:Number;	
		//public var throughable:Boolean;
		//内部计数器
		protected var inc:int;
		//构造函数
		public function Element(){
			score 		= 0;			
			life		= 5;
			hp			= life;
			execution	= 0;
			moveable	= true;
			hurtable	= true;
			explodeType = Explode.UNIT;
		}		
		//执行ILive接口
		public function live():void{
			if(hp<=0){
				explodeable = true;
				erasable = true;
			}
			if(hp>life){
				hp = life;
			}
		}
		//生命值属性
		public function set hp(value:Number):void{
			_hp = value;
			live();
		}
		public function get hp():Number{
			return _hp;
		}
		//分值属性
		public function set score(value:Number):void{
			_score = value;
		}
		public function get score():Number{
			return _score;
		}
	}
}